﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/BoUser.Master" Inherits="System.Web.Mvc.ViewPage" %>
<%@ Import Namespace="CWB.Web.DB" %>
<%@ Import Namespace="CWB.WebSite.Models.Agent" %>
<%@ Import Namespace="CWB.Web.Mvc.Extensions" %>

<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
	<%=Resources.Text.MenuMACreate %>
</asp:Content>
<asp:Content ID="Content5" ContentPlaceHolderID="BreadCrumbs" runat="server">
    <%=Resources.Text.MenuMA%> > <%=Resources.Text.MenuMACreate%>
</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <div id="content">
    <%
        AgentUpdateModel Model = (AgentUpdateModel)ViewData.Model;
        
    %>
        <form id="MACreate">
            <input type="hidden" id="parentSN" name="parentSN" value="<%=Model.Agent.uplinesn %>" />
            <table class="width100 ui-widget-content ui-corner-all">
            <COLGROUP>
              <COL WIDTH="20%">
              <COL WIDTH="30%">
              <COL WIDTH="20%">
              <COL WIDTH="30%">
            </COLGROUP>        
            <tbody>
	            <tr>
	                <td><% =Resources.Text.LabelAgLoginID%><%=Resources.Text.Label_Colon %></td>
	                <td>
	                    <%
                         CWB.Web.SessionData sessionData = new CWB.Web.SessionData();
                         if (sessionData != null && sessionData.trading != null && sessionData.trading.loginType == CWB.Common.Constant.LoginType.Bo)
                         {
                             %>
                                <input type="text" id="loginid" name="loginid" class="lowercase" />
                             <%
                         }
                         else
                         {
                             Response.Write(Model.parentLoginid.ToUpper());
                             %>
                                <input type="hidden" id="parentLoginid" name="parentLoginid" value="<%=Model.parentLoginid %>" />
                                <input type="hidden" id="loginid" name="loginid" value="" />
                                <select name="downlinerange" id="downlinerange">
                                <%
                                    foreach (string rang in Model.DownLineList)
                                    {
                                        Response.Write(string.Format("<option value=\"{0}\">{0}</option>\r\n", rang));
                                    }
                                %>
                                </select>
                             <%
                         }   	                    %>
	                    
	                </td>
	                <td class="txt-right"><% =Resources.Text.LabelAgUserName%><%=Resources.Text.Label_Colon %></td><td><input type="text" id="username" name="username"/></td>
	            </tr>
	            <tr>
	                <td><% =Resources.Text.LabelAgPresetCreditLimit%><%=Resources.Text.Label_Colon %></td><td><input type="text" id="creditlimit" name="creditlimit" class="decimal"/></td>
	                <td class="txt-right"><% =Resources.Text.Home_Login_PasswordLabel %><%=Resources.Text.Label_Colon %></td><td><input type="password" id="password" name="password" /></td>
	            </tr>
	            <tr>
	                <td><% =Resources.Text.LabelAgPossess%><%=Resources.Text.Label_Colon %></td>
	                        <td>
	                            <select id="possess" name="possess">
	                            <%
                                    int maxRange = Model.PossessRange;
                                    for (int i = 0; i <= maxRange; i++)
                                    {
                                        string isSelected = (i == Model.Agent.Possess) ? " selected " : "";
                                        Response.Write(string.Format("<option value=\"{0}\" {1}>{2}</option>", i, isSelected, i));
                                    }   
	                             %>
	                             </select>
	                        </td>
	                <td class="txt-right"><% =Resources.Text.Create_ConfirmPassword %><%=Resources.Text.Label_Colon %></td><td><input type="password" id="conpassword" /></td>
	            </tr>
	            <tr>
	                <td><% =Resources.Text.LabelNotes%><%=Resources.Text.Label_Colon %></td><td colspan="3" class="rightP5"><textarea id="notes" name="notes" class="width100"></textarea></td>
	            </tr>
	            <tr>
	                <td>ProductItems<%=Resources.Text.Label_Colon %></td>
	                <td colspan="3">
	                    <%
                        int _i = 0;
                        foreach (AgentUpdateProdItemModel prod in Model.ProdItems)
                        {
                            _i++;
                            string disabled = "disabled";
                            string bchecked = "";
                            if (prod.price > 0)
                            {
                                disabled = "";
                                bchecked = "checked";
                            }
                            string checkbox = string.Format("<div class=\"AgProdPrice\">$<input type=\"text\" name=\"supportedProdsPrice\" value=\"{0}\" {1} class=\"decimal\" />", prod.price, disabled);
                            checkbox += string.Format("<label for=\"p{0}\"><input type=\"checkbox\" name=\"supportedProds\" id=\"p{0}\" value=\"{1}\" {2} />({3}){4}</label></div>\n\r", _i, prod.sn, bchecked, prod.prodid, prod.prodName);
                            Response.Write(checkbox);
                        }   
	                    %>
	                </td>
	            </tr>
	            <tr><td colspan="4">
    	            <a href="#" id="btnSave" class="align-right ui-state-default ui-corner-all"><span class="align-right ui-icon ui-icon-pencil"></span><% =Resources.Text.Btn_Save %></a></td>
	            </tr>
            </tbody>	        
            </table>
        </form>
    </div>        
</asp:Content>

<asp:Content ID="Content3" ContentPlaceHolderID="header" runat="server">
</asp:Content>

<asp:Content ID="Content4" ContentPlaceHolderID="JSContent" runat="server">
    <script type="text/javascript" src="<%= Url.CdnContent("/js/Agent/AgentCreate.js") %>"></script>
</asp:Content>